import React, { Component } from 'react'
import {
    Home,
    Order,
    Mine,
    Cart,
    Menu,
    Detail
} from './pages';
import {
  Switch,
  Redirect,
  Route
} from 'react-router-dom' 
import Routers from './Routers';
import Tarbar from './tarbar';
import './index.less';


import Serech from './commonts/Serech';

import {connect} from 'react-redux'

const mapStae=state=>{
  return {
    isSubpage:state.ux.isSubpage
  }
}

const tarbarRoute=Routers.filter(route=>route.title)
 class App extends Component {
  
  
  
  render() {
    
     return (
      <div>
        <Serech />
        <Switch>
          {
            Routers.map((route)=>{
              return(
                <Route key={route.path} path={route.path} component={route.component} />
                
              )
            })
          }

          <Redirect exact from="/" to="/home" />
        </Switch>
        <div>

 {
  !this.props.isSubpage && 
  <Tarbar routes={tarbarRoute}/>
       
}

         
        </div>
      </div>
    )
  }
}

export default connect(mapStae)(App)